Repository navigation
fix: correct binding setup and helper replacement - #547
Merged
Merged
Conversation
- Dispose the forward subscription when reverse setup fails. - Cover generated and runtime binding failures. - Demonstrate failed setup without retaining the source.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #547 +/- ##
=======================================
Coverage 99.01% 99.01%
=======================================
Files 471 471
Lines 18848 18864 +16
Branches 2793 2793
=======================================
+ Hits 18663 18679 +16
Misses 185 185 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
4 tasks done
- Give a helper being initialized priority over the assigned helper. - Keep listeners current when activation replaces a helper. - Demonstrate helper replacement with an observed property.
|
glennawatson
added a commit
to reactiveui/ReactiveUI
that referenced
this pull request
Nov 17, 2026
<!-- Read the [Contribute guide](https://www.reactiveui.net/contribute/index.html) before opening a PR. --> <!-- Give this PR a title that follows [Conventional Commits](https://www.conventionalcommits.org/), e.g. `fix: dispose the binding when the view detaches`. --> <!-- Two people read this: the reviewer, and a user who followed a link here from the release notes. Fill in each section and keep it in proportion. A new subsystem earns more bullets; it never earns longer ones. A one-line fix earns one bullet. --> ## Summary <!-- One or two sentences on what this PR changes, then one bullet per distinct change. Write for someone who has not read the diff. Name the behaviour, type or API, not the files. One or two sentences per bullet, no sub-bullets. Cover everything the branch does. Describe the result, not the route you took to it, and not how it works inside. --> Typed property-change observers receive notifications even when bindings or event handlers initialize shared state through `IReactiveObject`. - Preserve the concrete sender and property name when notification arguments need adapting. - Keep compatible notification arguments unchanged. - Cover persistence, generated helper initialization and read-only WPF dependency-property observation through the packaged generators. ## Why <!-- The problem this solves. For a bug, say what went wrong and under what conditions. Link the issue and write `Closes #123` so it closes on merge. If there is no issue, say what prompted the change. --> `AutoPersist<T>` threw `InvalidCastException` when shared state was first accessed through an interface. The same cast also broke typed changing and changed observers. A notification's sender can have the requested concrete type even when its event-argument type uses `IReactiveObject`. Closes #4554. Refs #4538, #4541, #4547, #4549. ## Breaking changes <!-- Anything a consumer has to react to: removed or renamed public API, a changed default, different timing or threading, a new dependency, a dropped target framework. Say what breaks and what to write instead. Write "None" if nothing breaks. --> None. ## How this was verified <!-- One or two lines. What the new tests cover, and anything you exercised by hand. "Tests cover every class this adds" and "ran the sample app on Android and iOS" are complete answers. Never list test counts, pass or fail results, individual test names, or which frameworks went green. The checks tab reports all of that already. Say plainly if something could not be tested here. --> Tests cover mixed sender types, terminal signals, persistence, activation and dependent helper initialization. Exercised generated and runtime read-only WPF observation on real Windows, and compiled consumers of the current generator package with the .NET 8, 9, 10 and 11 compilers. ## Notes for the reviewer <!-- Where to start reading, and what deserves the most attention. Say which parts are mechanical and safe to skim, and which parts are subtle. Flag any decision you were unsure about, and anything you left out of scope on purpose. Screenshots, traces and links go here. --> Start with `ChangeArgsCastObservable`: adapt incompatible event arguments while preserving the sender and nullable property name. Its internal visibility permits direct protocol tests without reflection. The open reports were checked against current packages: | Report | Finding | | --- | --- | | #4554 | Fixed by the shared notification adapter. | | #4538 | Initial activation works; a related helper-replacement defect is fixed in reactiveui/ReactiveUI.SourceGenerators#547. | | #4541 | Constructor initialization works; retained as a downstream integration test. | | #4547 | Read-only dependency properties work through generated and runtime observation; retained as a Windows regression test. | | #4549 | Current package 5.0.0 loads across all three shipped Roslyn bands. The reported failure cannot be reproduced without its missing package and IDE version details. | Cobertura covers every executable line and branch in the changed production file. ## Checklist - [x] I have read the [Contribute guide](https://www.reactiveui.net/contribute/index.html) - [x] The PR title follows [Conventional Commits](https://www.conventionalcommits.org/) - [x] Tests cover this change, or the summary says why they do not - [x] New or changed public API has XML documentation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Summary
Two-way bindings clean up partial setup failures, and generated output properties expose the current value when their helper is replaced.
BindTwoWay, source-firstBindTwoWayUnsafeand view-firstBindUnsafe.Why
If a target rejects notification subscription, binding creation throws without returning a disposable, but later source edits still update the target.
Reviewing ReactiveUI's activation reports also exposed a related generated-getter defect: replacing a helper raises notifications before the helper field is reassigned, so listeners read the previous helper's value. This can leave a reactivated view displaying a stale value.
The binding generator and runtime are maintained here; ReactiveUI consumes this binding package, and the former standalone binding-generator repository is archived. Refs reactiveui/ReactiveUI#4538.
Breaking changes
None.
How this was verified
Regression tests cover rejected subscriptions, converter overloads, view-first runtime bindings and synchronous helper replacement. Exercised documentation and platform examples on Linux and Windows, plus a .NET 11 Native AOT consumer; Apple examples require an Apple host.
Notes for the reviewer
Start with reverse subscription setup in
BindTwoWayCodeGeneratorandRuntimeBindingFallback, then the getter emitted byObservableAsPropertyGenerator. The getter must consult the helper being constructed even when its field contains an older helper. Snapshot changes repeat the emitted cleanup and getter updates.Cobertura covers every executable line and branch in the changed production files. The downstream ReactiveUI review separately fixes interface-initialized notification state.
Checklist